<template>
  <div class="center-right">
    <div class="topSearch">
      <input v-model="searchName" type="text" placeholder="please enter">
      <div class="searchBtn" @click="search">
        <img src="@/assets/loginImgs/search.png" alt="">
      </div>
    </div>
    <div class="right-top">
      <div class="up-header1">
        <el-breadcrumb separator-class="el-icon-arrow-right">
          <el-breadcrumb-item>{{ detialData.title }}</el-breadcrumb-item>
          <!-- <el-breadcrumb-item>logistics</el-breadcrumb-item> -->
        </el-breadcrumb>
      </div>
      <div class="up">
        <div class="up-footer">
          <div v-if="!detialData.content && !loading" class="nodata">
            <img
              style="width: 140px;"
              src="@/assets/loginImgs/nodata.png"
              alt=""
            >
          </div>
          <p class="content-img" v-html="detialData.content" />
        </div>
        <div class="update-text">
          <p>Published time: {{ detialData.publishedTime }}</p>
        </div>
      </div>
    </div>
    <!-- <div class="right-bottom">
      <div class="up">
        <div class="up-header">
          You also need to know
        </div>
        <div class="up-footer2">
          <div v-if="!mustList.length" class="nodata">
            <img
              style="width: 140px;"
              src="@/assets/loginImgs/nodata.png"
              alt=""
            >
          </div>
          <ul>
            <li v-for="item in mustList" :key="item.id">
              <span @click="goCategoryDetial(item.id, item.title)">{{
                item.title
              }}</span>
            </li>
          </ul>
        </div>
      </div>
    </div> -->
  </div>
</template>

<script>
import { articleRead, articleTextTutorialMust } from '@/api/article';
export default {
  props: {
    title: {
      type: String,
      default: ''
    },
    id: {
      type: Number,
      default: 0
    },
    categoryId: {
      type: Number,
      default: -1
    }
  },
  data() {
    return {
      detialId: '',
      name: '',
      detialData: {},
      mustList: [],
      isShow: false,
      searchName: '',
      threeMenuShow: false,
      loading: true
    };
  },
  mounted() {
    this.getDetial(this.id);
    this.getMust();
    this.$nextTick(function() {
      if (
        document.documentElement.clientHeight >
        document.getElementsByClassName('content')[0].clientHeight
      ) {
        document.getElementsByClassName('content')[0].style.minHeight =
          document.documentElement.clientHeight -
          document.getElementsByClassName('header')[0].clientHeight -
          document.getElementsByClassName('footer')[0].clientHeight +
          'px';
      } else {
        document.getElementsByClassName('content')[0].style.minHeight =
          950 -
          document.getElementsByClassName('header')[0].clientHeight -
          document.getElementsByClassName('footer')[0].clientHeight +
          'px';
      }
    });
  },
  methods: {
    goCategoryDetial(id, title) {
      this.getDetial(id);
      // this.$emit('category', { id: id, name: title, type: 'detial' });
    },
    search() {
      this.$emit('category', { id: this.categoryId, searchName: this.searchName, name: this.title });
    },
    nextMenu() {
      this.isShow = !this.isShow;
    },
    threeMenu() {
      this.threeMenuShow = !this.threeMenuShow;
    },
    getMust() {
      articleTextTutorialMust().then((res) => {
        this.mustList = res.data.data;
      });
    },
    getDetial(id) {
      this.loading = true;
      articleRead(id).then((res) => {
        if (res.code === 200) {
          this.loading = false;
          this.detialData = res.data;
        }
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.nodata {
  text-align: center;
  margin: 50px;
}
.content {
  width: 100%;
  height: 100%;
  margin-top: 70px;
  // padding-bottom: calc(100vw / 28.4);
  background: #f9f9f9;
}
.topSearch {
  height: 46px;
  text-align: center;
  position: relative;
  margin-bottom: 30px;
  // overflow: hidden;
  input {
    width: 930px;
    height: 46px;
    padding: 0 40px;
    line-height: 46px;
    // margin: 10px 0;
    font-size: 18px;
    outline: none;
    color: #666666;
    background: rgba(255, 255, 255, 1);
    border: 1px solid #e6e6e6;
  }
  .searchBtn {
    position: absolute;
    top: 10px;
    left: 10px;
    img {
      width: 20px;
      height: 20px;
      margin-top: 5px;
    }
  }
}
.center {
  width: 1200px;
  margin: 0 auto;
  // margin-top: calc(100vw / 14.77 / -1);
  &-right {
    width: 930px;
    height: 100%;
    display: inline-block;
    > div {
      background: rgba(255, 255, 255, 1);
    }
    .up-header1 {
      width: 930px;
      height: 39px;
      padding-left: 30px;
      color: #e6e6e6;
      border: 1px solid #e6e6e6;
      border-bottom: 0;
      .el-breadcrumb {
        height: 39px;
        line-height: 39px;
      }
      span {
        font-size: 16px;
        color: #02a152;
      }
    }
    .up {
      padding: 20px 30px;
      // margin-top: calc(100vw / 96);
      border: 1px solid #e6e6e6;
      &-header {
        // width: calc(100vw / 4.26);
        height: calc(100vw / 53.33);
        font-size: calc(100vw / 120);
        color: #333333;
        line-height: calc(100vw / 53.33);
        padding-left: calc(100vw / 96);
        background: rgba(249, 249, 249, 1);
        border: 1px solid rgba(211, 211, 211, 1);
      }
      &-footer {
        p {
          word-wrap: break-word;
          min-height: 300px;
          ::v-deep img {
            max-width: 100% !important;
            max-height: 100% !important;
          }
        }
      }
      &-footer2 {
        // width: calc(100vw / 4.26);
        font-size: calc(100vw / 137.14);
        color: rgba(2, 161, 82, 1);
        padding: calc(100vw / 80) calc(100vw / 80) calc(100vw / 80)
          calc(100vw / 50);
        border: 1px solid lightgray;
        border-top: 0;
        ul {
          margin: 0;
          padding: 0;
          li {
            // padding: calc(100vw / 180) 0;
            line-height: calc(100vw / 80);
            span {
              cursor: pointer;
              white-space: nowrap;
              overflow: hidden;
              text-overflow: ellipsis;
              display: block;
              padding: calc(100vw / 384) 0;
            }
          }
        }
      }
      .update-text {
        height: 40px;
        line-height: 40px;
        border-top: calc(100vw / 960) solid #e6e6e6;
        p {
          text-align: end;
          font-size: 14px;
        }
      }
    }
    .right-bottom {
      .up {
        margin: calc(100vw / 64) 0;
        &-footer {
          color: rgba(2, 161, 82, 1);
          margin: 0 calc(100vw / 33.1);
          ul {
            list-style-type: initial;
          }
        }
      }
    }
    .right-top {
      background: rgba(255, 255, 255, 1);
      // box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.16);
      // opacity: 1;
      // // border-radius: 0px calc(100vw / 480) calc(100vw / 480) calc(100vw / 480);
    }
  }
  .transition-box {
    margin-bottom: 10px;
    width: 200px;
    height: 100px;
    border-radius: 4px;
    background-color: #409eff;
    text-align: center;
    color: #fff;
    padding: 40px 20px;
    box-sizing: border-box;
    margin-right: 20px;
  }
}
</style>
